using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;


namespace Pong_Take1
{
    /// <summary>
    /// This is a game component that implements IUpdateable.
    /// </summary>
    public class Ball : Microsoft.Xna.Framework.DrawableGameComponent
    {        
        public Vector2 ballPos;
        public Vector2 ballCenter;               

        public BoundingSphere ballBound;

        public Texture2D ballTexture;
        
        public Ball(Game game, Vector2 ballPos)
            : base(game)
        {
            // TODO: Construct any child components here
            this.ballPos = ballPos;                        
        }

        /// <summary>
        /// Allows the game component to perform any initialization it needs to before starting
        /// to run.  This is where it can query for any required services and load content.
        /// </summary>
        public override void Initialize()
        {
            // TODO: Add your initialization code here            
            base.Initialize();
        }

        /// <summary>
        /// Allows the game component to update itself.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        public override void Update(GameTime gameTime)
        {
            // TODO: Add your update code here
            ballCenter.X = ballPos.X + ballTexture.Width / 2;
            ballCenter.Y = ballPos.Y + ballTexture.Width / 2;

            ballBound = new BoundingSphere(new Vector3(ballCenter, 0), ballTexture.Height / 2);

            
            base.Update(gameTime);
        }

        public void Draw(SpriteBatch sb)
        {            
            sb.Draw(this.ballTexture, ballPos, Color.White);                        
        }
    }
}
